```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Redis淘汰机制详解 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .first-letter {
            font-size: 3.5em;
            float: left;
            line-height: 0.8;
            margin-right: 0.1em;
            color: #4f46e5;
            font-weight: 700;
        }
        .divider {
            height: 1px;
            background: linear-gradient(90deg, rgba(79,70,229,0) 0%, rgba(79,70,229,0.5) 50%, rgba(79,70,229,0) 100%);
            margin: 2rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl flex flex-col items-center text-center">
            <div class="w-20 h-20 bg-white rounded-lg flex items-center justify-center mb-6 shadow-lg">
                <i class="fas fa-database text-4xl text-indigo-600"></i>
            </div>
            <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">Redis淘汰机制详解</h1>
            <p class="text-xl md:text-2xl max-w-2xl mb-8 opacity-90">内存有限，数据无限 — Redis如何优雅管理内存资源</p>
            <div class="bg-white bg-opacity-10 rounded-lg p-4 md:p-6 max-w-3xl backdrop-filter backdrop-blur-sm">
                <p class="text-lg md:text-xl italic">"在内存不足时，Redis通过智能淘汰机制确保系统稳定运行，将冷数据及时清理，释放内存空间。"</p>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="flex items-start">
                <span class="first-letter">R</span>
                <p class="text-lg leading-relaxed text-gray-700">
                    edis中的淘汰机制是为了在内存不足时，有效管理数据的过期与淘汰以保障系统的稳定性。内存是有最大限制的，如果Redis中存放的key已经到了极限，就要触发淘汰机制，来保缓存中存放的数据都是热数据，把冷数据及时的清理，释放内存空间。
                </p>
            </div>
        </section>

        <!-- Summary Diagram -->
        <section class="mb-16 bg-white rounded-xl shadow-md p-6">
            <h2 class="text-2xl font-bold mb-6 text-indigo-700 flex items-center">
                <i class="fas fa-project-diagram mr-3"></i> Redis淘汰机制概览
            </h2>
            <div class="mermaid">
                graph TD
                    A[Redis淘汰机制] --> B[LRU]
                    A --> C[LFU]
                    A --> D[TTL]
                    A --> E[定期删除]
                    A --> F[随机淘汰]
                    A --> G[noeviction]
                    
                    B --> B1[最近最少使用]
                    C --> C1[最不经常使用]
                    D --> D1[生存时间到期]
                    E --> E1[定期检查过期键]
                    F --> F1[随机选择键]
                    G --> G1[拒绝写入]
            </div>
        </section>

        <!-- LRU Section -->
        <section class="mb-16">
            <div class="flex flex-col md:flex-row gap-8 items-start">
                <div class="md:w-1/2">
                    <h2 class="text-2xl font-bold mb-4 text-indigo-700 flex items-center">
                        <i class="fas fa-clock mr-3"></i> LRU (最近最少使用)
                    </h2>
                    <p class="text-gray-700 mb-4">LRU算法是一种基于使用频率的淘汰机制，当内存不足以存储新的数据时，系统会淘汰最近最少使用的数据。</p>
                    <p class="text-gray-700">Redis通过记录键的访问时间通过LRU算法判断哪些键最久未被使用然后将其淘汰。</p>
                    <div class="mt-6 bg-indigo-50 rounded-lg p-4 border-l-4 border-indigo-500">
                        <p class="text-indigo-700 font-medium">应用场景：适用于访问模式相对均匀，但需要优先保留最近活跃数据的场景。</p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white rounded-lg overflow-hidden shadow-md card-hover">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1705887594455-76b8b31f-fef5-4381-b368-1b658b87cb7b.png" alt="LRU算法示意图" class="w-full h-auto">
                    </div>
                </div>
            </div>
        </section>

        <!-- LFU Section -->
        <section class="mb-16">
            <div class="flex flex-col md:flex-row-reverse gap-8 items-start">
                <div class="md:w-1/2">
                    <h2 class="text-2xl font-bold mb-4 text-indigo-700 flex items-center">
                        <i class="fas fa-chart-line mr-3"></i> LFU (最不经常使用)
                    </h2>
                    <p class="text-gray-700 mb-4">LFU算法是一种基于使用频率的淘汰机制，它考虑键的使用频率将使用频率最低的键淘汰。</p>
                    <p class="text-gray-700">Redis会通过计数器记录键的使用次数并在需要淘汰数据时选择使用频率最低的键进行淘汰。</p>
                    <div class="mt-6 bg-indigo-50 rounded-lg p-4 border-l-4 border-indigo-500">
                        <p class="text-indigo-700 font-medium">应用场景：适用于有明显热点数据，希望长期保留高频访问数据的场景。</p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white rounded-lg overflow-hidden shadow-md card-hover">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1705887479232-7cd01e33-7bc1-4258-9183-82a30ddfc3ea.png" alt="LFU算法示意图" class="w-full h-auto">
                    </div>
                </div>
            </div>
        </section>

        <!-- TTL Section -->
        <section class="mb-16">
            <div class="flex flex-col md:flex-row gap-8 items-start">
                <div class="md:w-1/2">
                    <h2 class="text-2xl font-bold mb-4 text-indigo-700 flex items-center">
                        <i class="fas fa-hourglass-half mr-3"></i> TTL (生存时间)
                    </h2>
                    <p class="text-gray-700 mb-4">Redis允许为每个键设置过期时间，即TTL一旦键过期系统会自动将其淘汰。</p>
                    <p class="text-gray-700">这种方式适用于需要在一定时间内保留的临时数据，如缓存。</p>
                    <div class="mt-6 bg-indigo-50 rounded-lg p-4 border-l-4 border-indigo-500">
                        <p class="text-indigo-700 font-medium">应用场景：适用于临时缓存数据、会话信息等有明确生命周期的数据。</p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white rounded-lg overflow-hidden shadow-md card-hover">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1705887743314-129c6f8c-d1f3-4abc-9642-92d248048c85.png" alt="TTL示意图" class="w-full h-auto">
                    </div>
                </div>
            </div>
        </section>

        <!-- Regular Deletion Section -->
        <section class="mb-16">
            <div class="flex flex-col md:flex-row-reverse gap-8 items-start">
                <div class="md:w-1/2">
                    <h2 class="text-2xl font-bold mb-4 text-indigo-700 flex items-center">
                        <i class="fas fa-calendar-check mr-3"></i> 定期删除
                    </h2>
                    <p class="text-gray-700 mb-4">定期删除是一种简单的淘汰机制，系统会定期检查键的过期时间并删除已经过期的键。</p>
                    <p class="text-gray-700">这种方式虽然不够智能，但可以在一定程度上释放内存。</p>
                    <div class="mt-6 bg-indigo-50 rounded-lg p-4 border-l-4 border-indigo-500">
                        <p class="text-indigo-700 font-medium">应用场景：作为TTL的补充机制，确保过期数据能够被及时清理。</p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white rounded-lg overflow-hidden shadow-md card-hover">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1705887863443-a6536c09-6859-4bec-8628-4c2098ec4ed4.png" alt="定期删除示意图" class="w-full h-auto">
                    </div>
                </div>
            </div>
        </section>

        <!-- Random Eviction Section -->
        <section class="mb-16">
            <div class="flex flex-col md:flex-row gap-8 items-start">
                <div class="md:w-1/2">
                    <h2 class="text-2xl font-bold mb-4 text-indigo-700 flex items-center">
                        <i class="fas fa-random mr-3"></i> 随机淘汰
                    </h2>
                    <p class="text-gray-700 mb-4">随机淘汰是一种简单的淘汰策略，系统随机选择一个键进行淘汰。</p>
                    <p class="text-gray-700">尽管这种方法不考虑键的使用频率或过期时间，但在某些场景下是一种简便有效的方式。</p>
                    <div class="mt-6 bg-indigo-50 rounded-lg p-4 border-l-4 border-indigo-500">
                        <p class="text-indigo-700 font-medium">应用场景：适用于数据重要性相当，没有明显热点数据的场景。</p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white rounded-lg overflow-hidden shadow-md card-hover">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1705887931662-fca002f8-9fa4-4ecf-afd7-daff1be0521c.png" alt="随机淘汰示意图" class="w-full h-auto">
                    </div>
                </div>
            </div>
        </section>

        <!-- Noeviction Section -->
        <section class="mb-16">
            <div class="flex flex-col md:flex-row-reverse gap-8 items-start">
                <div class="md:w-1/2">
                    <h2 class="text-2xl font-bold mb-4 text-indigo-700 flex items-center">
                        <i class="fas fa-ban mr-3"></i> noeviction
                    </h2>
                    <p class="text-gray-700 mb-4">它是Redis的默认策略，在内存超过阈值后Redis不做任何清理工作然后对所有写操作返回错误，但对读请求正常处理。</p>
                    <p class="text-gray-700">noeviction适合数据量不大的业务场景，将关键数据存入Redis中将Redis当作DB来使用。</p>
                    <div class="mt-6 bg-indigo-50 rounded-lg p-4 border-l-4 border-indigo-500">
                        <p class="text-indigo-700 font-medium">应用场景：适用于将Redis作为持久化数据库使用，且数据量不会超过内存容量的场景。</p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white rounded-lg overflow-hidden shadow-md card-hover">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1705888076077-9eb1eaa8-864c-4a1d-8d62-c0d5a9eceeb3.png" alt="noeviction示意图" class="w-full h-auto">
                    </div>
                </div>
            </div>
        </section>

        <!-- Detailed Strategies -->
        <section class="mb-16 bg-white rounded-xl shadow-md overflow-hidden">
            <div class="bg-indigo-600 text-white p-6">
                <h2 class="text-2xl font-bold flex items-center">
                    <i class="fas fa-cogs mr-3"></i> Redis详细淘汰策略
                </h2>
            </div>
            <div class="p-6">
                <ul class="space-y-4">
                    <li class="flex items-start">
                        <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3 mt-1">
                            <span class="text-indigo-600 font-bold">1</span>
                        </div>
                        <div>
                            <p class="font-medium text-gray-800">volatile-lru：在内存不足时，Redis会在设置过了生存时间的key中淘汰一个最近最少使用的key。</p>
                        </div>
                    </li>
                    <li class="flex items-start">
                        <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3 mt-1">
                            <span class="text-indigo-600 font-bold">2</span>
                        </div>
                        <div>
                            <p class="font-medium text-gray-800">allkeys-lru：在内存不足时，Redis会在全部的key中淘汰一个最近最少使用的key。</p>
                        </div>
                    </li>
                    <li class="flex items-start">
                        <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3 mt-1">
                            <span class="text-indigo-600 font-bold">3</span>
                        </div>
                        <div>
                            <p class="font-medium text-gray-800">volatile-lfu：在内存不足时，Redis会在设置过了生存时间的key中淘汰一个最近最少频次使用的key。</p>
                        </div>
                    </li>
                    <li class="flex items-start">
                        <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3 mt-1">
                            <span class="text-indigo-600 font-bold">4</span>
                        </div>
                        <div>
                            <p class="font-medium text-gray-800">allkeys-lfu：在内存不足时，Redis会在全部的key中淘汰一个最近最少频次使用的key。</p>
                        </div>
                    </li>
                    <li class="flex items-start">
                        <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3 mt-1">
                            <span class="text-indigo-600 font-bold">5</span>
                        </div>
                        <div>
                            <p class="font-medium text-gray-800">volatile-random：在内存不足时，Redis会在设置过了生存时间的key中随机淘汰一个。</p>
                        </div>
                    </li>
                    <li class="flex items-start">
                        <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3 mt-1">
                            <span class="text-indigo-600 font-bold">6</span>
                        </div>
                        <div>
                            <p class="font-medium text-gray-800">allkeys-random：在内存不足时，Redis会在全部的key中随机淘汰一个。</p>
                        </div>
                    </li>
                    <li class="flex items-start">
                        <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3 mt-1">
                            <span class="text-indigo-600 font-bold">7</span>
                        </div>
                        <div>
                            <p class="font-medium text-gray-800">volatile-ttl：在内存不足时，Redis会在设置过了生存时间的key中淘汰一个剩余生存时间最少的key。</p>
                        </div>
                    </li>
                    <li class="flex items-start">
                        <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3 mt-1">
                            <span class="text-indigo-600 font-bold">8</span>
                        </div>
                        <div>
                            <p class="font-medium text-gray-800">noeviction：（默认）在内存不足时，直接报错，支持读，不支持写。</p>
                        </div>
                    </li>
                </ul>
            </div>
        </section>

        <!-- Conclusion -->
        <section class="bg-white rounded-xl shadow-md p-6 mb-16">
            <h2 class="text-2xl font-bold mb-6 text-indigo-700">总结</h2>
            <div class="flex items-start">
                <div class="flex-shrink-0 mt-1 mr-4">
                    <i class="fas fa-lightbulb text-2xl text-yellow-500"></i>
                </div>
                <div>
                    <p class="text-gray-700 mb-4">这些淘汰机制可以根据具体场景和需求选择合适的方式，以在内存有限的情况下更好地维护系统的性能和稳定性。</p>
                    <p class="text-gray-700">在选择淘汰策略时，需要考虑数据访问模式、数据重要性、性能要求等因素，找到最适合业务场景的平衡点。</p>
                </div>
            </div>
        </section>

        <!-- Visual Summary -->
        <section class="bg-white rounded-xl shadow-md overflow-hidden mb-16">
            <div class="p-6">
                <div class="bg-white rounded-lg overflow-hidden">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1705888142953-d0aad9c0-dbfd-4472-9a19-afd6a84c78d6.png" alt="Redis淘汰机制总结图" class="w-full h-auto">
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto px-4 max-w-5xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">专业的IT技术知识分享平台</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-indigo-400 hover:text-indigo-300 transition-colors duration-300 flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        <span>访问技术小馆语雀</span>
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-6 pt-6 text-center text-gray-500 text-sm">
                &copy; 2024 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```